select @userRole:=DcRoleId from DcRole where RoleName='Users';
select @commonDept:=DepartmentId from Department where Name='Common';

insert into DcUser values (default, "DocCircUser1", PASSWORD("1"), "DocCirc User 1", false, true, @commonDept, false, "", false, false, "");
set @lastUser = last_insert_id();
insert into UserEmail values (default, @lastUser, "doccircuser1@debug.org");
insert into RoleToUser values (default, @userRole, @lastUser, 1);

insert into DcUser values (default, "DocCircUser2", PASSWORD("1"), "DocCirc User 2", false, true, @commonDept, false, "", false, false, "");
set @lastUser = last_insert_id();
insert into UserEmail values (default, @lastUser, "doccircuser2@debug.org");
insert into RoleToUser values (default, @userRole, @lastUser, 1);

insert into DcUser values (default, "DocCircUser3", PASSWORD("1"), "DocCirc User 3", false, true, @commonDept, false, "", false, false, "");
set @lastUser = last_insert_id();
insert into UserEmail values (default, @lastUser, "doccircuser3@debug.org");
insert into RoleToUser values (default, @userRole, @lastUser, 1);

select @docTypeFT:=FolderTypeId from FolderType where Name='DocType';
select @docTypeRoot:=FolderId from Folder where FolderType=@docTypeFT and IsNull(ParentFolder);
insert into Folder (FolderId, ParentFolder, Name, FolderType)
	Values (default, @docTypeRoot, 'Test DocType folder1', @docTypeFT);
	
insert into FolderPermission (DcRole, Folder, C, R, U, D, B, RO, UO, DO)
	select DcRole, last_insert_id(), C, R, U, D, B, RO, UO, DO from NewFolderPermission
	where FolderType=@docTypeFT;
